﻿@{
    // Connecting to webservices
    RemoteService.WebRemoteServiceClient _remoteService = new RemoteService.WebRemoteServiceClient();
    
    List<RemoteService.ScreenCast_Seat> screenSeats = new List<RemoteService.ScreenCast_Seat>();
    
    // Getting screenCast
    RemoteService.ScreenCast screenCast = _remoteService.GetScreenCast(Convert.ToInt32(Request.Cookies["screenCast"].Value));

    // Getting ScreenCast_Seats (with reference to Seat object)
    screenSeats = _remoteService.GetScreenCastSeats(screenCast);

    // Order screenSeat by seat row and number
    screenSeats = screenSeats.OrderBy(sc => sc.Seat.Row).ThenBy(sc => sc.Seat.Number).ToList();

    // Used to add new tr if seat is on a new row
    int lastRow = 0;
}

<!-- This is added to the movie page through jquery -->
<table style="border-spacing: 1px; border: 1px solid #000; float:left;"><tr><td style="background-color: #000; height: 5px;" colspan="@screenSeats.Count"></td></tr><tr> @foreach(RemoteService.ScreenCast_Seat ss in screenSeats)
                                                                                                                                                                                     {
                                                                                                                                                                                         if (ss.Seat.Row != lastRow)
                                                                                                                                                                                         { <tr></tr> lastRow = ss.Seat.Row;
                                                                                                                                                                                                 } if (ss.SeatAvailable)
                                                                                                                                                                                                 { <td style="background-color: #52b656; margin: 1px; padding: 0; height: 40px; width: 40px; border-spacing: 1px; border: 2px solid #efeeef; text-align:center;">@ss.Seat.Number</td> }
                                                                                                                                                                                                 else
                                                                                                                                                                                                 { <td style="background-color: #f00; margin: 1px; padding: 0; height: 40px; width: 40px; border-spacing: 1px; border: 2px solid #efeeef; text-align:center;">@ss.Seat.Number</td> }
                                                                                                                                                                                                 }</tr></table>